package qf.sail.entity;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class Good extends BaseEntity{
    private String goodNumber;  //商品编号

    private String goodName;    //商品名

    private String color;   //商品可选颜色

    private String size;    //商品可选尺码

    private int inventory;  //商品存货

    private BigDecimal oldPrice; //商品原价

    private BigDecimal newPrice;    //商品现价

    private  String goodPic;    //商品图片

    private int weight; //商品重量

    private String headPic; //第一张图片

    private int salesVolume;    //销量

    private int sexType;    //穿着性别 1代表男装 2代表女装

    private int wearType;   //服装类型 1：上衣，2：下衣 3：套装 4：内衣

    private String launchTime;  //上架时间

    private BigDecimal startFreight = new BigDecimal(0);    //首件运费

    private BigDecimal addFreight = new BigDecimal(0);      //加件运费

    public Good() {
    }

    public String getGoodNumber() {
        return goodNumber;
    }

    public void setGoodNumber(String goodNumber) {
        this.goodNumber = goodNumber;
    }

    public String getGoodName() {
        return goodName;
    }

    public void setGoodName(String goodName) {
        this.goodName = goodName;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public int getInventory() {
        return inventory;
    }

    public void setInventory(int inventory) {
        this.inventory = inventory;
    }

    public BigDecimal getOldPrice() {
        return oldPrice;
    }

    public void setOldPrice(BigDecimal oldPrice) {
        this.oldPrice = oldPrice;
    }

    public BigDecimal getNewPrice() {
        return newPrice;
    }

    public void setNewPrice(BigDecimal newPrice) {
        this.newPrice = newPrice;
    }

    public String getGoodPic() {
        return goodPic;
    }

    public void setGoodPic(String goodPic) {
        this.goodPic = goodPic;
        setHeadPic();
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public void setHeadPic(){
        String[] pics = goodPic.split(",");
        headPic = pics[0];
    }

    public String getHeadPic() {
        return headPic;
    }

    public int getSalesVolume() {
        return salesVolume;
    }

    public void setSalesVolume(int salesVolume) {
        this.salesVolume = salesVolume;
    }

    public int getSexType() {
        return sexType;
    }

    public void setSexType(int sexType) {
        this.sexType = sexType;
    }

    public int getWearType() {
        return wearType;
    }

    public void setWearType(int wearType) {
        this.wearType = wearType;
    }

    public String getLaunchTime() {
        return launchTime;
    }

    public void setLaunchTime(String launchTime) {
        this.launchTime = launchTime;
    }

    public BigDecimal getStartFreight() {
        return startFreight;
    }

    public void setStartFreight(BigDecimal startFreight) {
        this.startFreight = startFreight;
    }

    public BigDecimal getAddFreight() {
        return addFreight;
    }

    public void setAddFreight(BigDecimal addFreight) {
        this.addFreight = addFreight;
    }

    @Override
    public void setCreateTime(Timestamp createTime) {
        super.setCreateTime(createTime);
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        this.launchTime = sdf.format(createTime);
    }

    @Override
    public String toString() {
        return "Good{" +
                "goodNumber='" + goodNumber + '\'' +
                ", goodName='" + goodName + '\'' +
                ", color='" + color + '\'' +
                ", size='" + size + '\'' +
                ", inventory=" + inventory +
                ", oldPrice=" + oldPrice +
                ", newPrice=" + newPrice +
                ", goodPic='" + goodPic + '\'' +
                ", weight=" + weight +
                ", headPic='" + headPic + '\'' +
                ", salesVolume=" + salesVolume +
                ", sexType=" + sexType +
                ", wearType=" + wearType +
                ", launchTime='" + launchTime + '\'' +
                ", startFreight=" + startFreight +
                ", addFreight=" + addFreight +
                '}';
    }
}
